home *** CD-ROM | disk | FTP | other *** search
/ PD Collection CD 1 / PD Collection CD 1.iso / textual / tex / files / !tex / TeXsource / commontex / c / evalstack < prev    next >
Encoding:
Text File  |  1988-04-08  |  3.3 KB  |  184 lines

  1. /*
  2.  *    Copyright 1986, 1987 Pat Joseph Monardo. All rights reserved.
  3.  *    Copying of this file is granted according to the provisions 
  4.  *    specified in the file COPYING which must accompany this file.
  5.  */
  6.  
  7.  
  8. /*
  9.  *        evalstack.c
  10.  */
  11.  
  12. #include "tex.h"
  13. #include "cmds.h"
  14. #include "heap.h"
  15. #include "str.h"
  16. #include "arith.h"
  17. #include "tokenstack.h"
  18. #include "eq.h"
  19. #include "box.h"
  20. #include "page.h"
  21. #include "print.h"
  22. #include "error.h"
  23. #include "evalstack.h"
  24.  
  25. list    cur_list;
  26. list    nest[NEST_SIZE];
  27. ptr        nest_ptr;
  28. int        max_nest_stack;
  29. int        shown_mode;
  30.  
  31. push_nest ()
  32. {
  33.     if (nest_ptr > max_nest_stack) {
  34.         max_nest_stack = nest_ptr;
  35.         if (nest_ptr == NEST_SIZE)
  36.             overflow("semantic nest size", NEST_SIZE);
  37.     }
  38.     nest[nest_ptr] = cur_list;
  39.     incr(nest_ptr);
  40.     head = get_avail();
  41.     tail = head;
  42.     prev_graf = 0;
  43.     mode_line = line;
  44. }
  45.  
  46. pop_nest ()
  47. {
  48.     free_avail(head);
  49.     decr(nest_ptr);
  50.     cur_list = nest[nest_ptr];
  51. }
  52.  
  53. print_mode (m)
  54.     int        m;
  55. {
  56.     if (m > 0) {
  57.         switch (m / (MAX_COMMAND + 1))
  58.         {
  59.         case 0:
  60.             print("vertical");
  61.             break;
  62.  
  63.         case 1:
  64.             print("horizontal");
  65.             break;
  66.  
  67.         case 2:
  68.             print("display math");
  69.             break;
  70.         }
  71.     } else if (m == 0)
  72.         print("no");
  73.      else {    
  74.         switch (-m / (MAX_COMMAND + 1)) 
  75.         {
  76.         case 0:
  77.             print("internal vertical");
  78.             break;
  79.  
  80.         case 1:
  81.             print("restricted horizontal");
  82.             break;
  83.  
  84.         case 2:    
  85.             print("math");
  86.             break;
  87.         }
  88.     }
  89.     print(" mode");
  90. }
  91.  
  92. show_activities ()
  93. {
  94.     val        a;
  95.     int        p;
  96.     int        m;
  97.     ptr        q;
  98.     ptr        r;
  99.     val        t;
  100.  
  101.     nest[nest_ptr] = cur_list;
  102.     print_nl("");
  103.     print_ln();
  104.     for (p = nest_ptr; p >= 0; decr(p)) {
  105.         m = nest[p].mode_field;
  106.         a = nest[p].aux_field;
  107.         print_nl("### ");
  108.         print_mode(m);
  109.         print(" entered at line ");
  110.         print_val(abs(nest[p].ml_field));
  111.         if (nest[p].ml_field < 0)
  112.             print(" (\\output routine)");
  113.         if (p == 0) {
  114.             if (page_head != page_tail) {
  115.                 print_nl("### current page:");
  116.                 if (output_active)
  117.                     print(" (held over for next output)");
  118.                 show_box(link(page_head));
  119.                 if (page_contents > EMPTY) {
  120.                     print_nl("total height ");
  121.                     print_totals();
  122.                     print_nl(" goal height ");
  123.                     print_scaled(page_goal);
  124.                     r = link(page_ins_head);
  125.                     while (r != page_ins_head) {
  126.                         print_ln();
  127.                         print_esc("insert");
  128.                         t = qo(subtype(r));
  129.                         print_int((int) t);
  130.                         print(" adds ");
  131.                         t = x_over_n(height(r), 1000L) * count(t);
  132.                         print_scaled((scal) t);
  133.                         if (type(r) == SPLIT_UP) {
  134.                             q = page_head;
  135.                             t = 0;
  136.                             do    {
  137.                                 q = link(q);
  138.                                 if (type(q) == INS_NODE && 
  139.                                     subtype(q) == subtype(r))
  140.                                     incr(t);
  141.                             } while (q != broken_ins(r));
  142.                             print(", #");
  143.                             print_int((int) t);
  144.                             print(" might split");
  145.                         }
  146.                         r = link(r);
  147.                     }
  148.                 }
  149.             }
  150.             if (link(contrib_head) != NULL)
  151.                 print_nl("### recent contributions:");
  152.         }
  153.         show_box(link(nest[p].head_field)); 
  154.         switch (abs(m) / (MAX_COMMAND + 1))
  155.         {
  156.         case 0:
  157.             print_nl("prevdepth ");
  158.             if (a <= IGNORE_DEPTH)
  159.                 print("ignored");
  160.             else print_scaled((scal) a);
  161.             if (nest[p].pg_field != 0) {
  162.                 print(", prevgraf ");
  163.                 print_int(nest[p].pg_field);
  164.                 print(" line");
  165.                 if (nest[p].pg_field != 1)
  166.                     print_char('s');
  167.             }
  168.             break;
  169.  
  170.         case 1:
  171.             print_nl("spacefactor ");
  172.             print_int((int) a);
  173.             break;
  174.  
  175.         case 2:
  176.             if (a != NULL) {
  177.                 print("this will be a denominator of:");
  178.                 show_box((ptr) a);
  179.             }
  180.             break;
  181.         }
  182.     }
  183. }
  184.